home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / lib / IdentSet.c < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  82 lines

  1. /* IdentSet.c -- implementation of Identity Set
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2033
  13.     Computer Systems Laboratory
  14.     Division of Computer Research and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-1111
  18.     uucp: uunet!nih-csl!kgorlen
  19.     Internet: kgorlen@alw.nih.gov
  20.     April, 1988
  21.  
  22. Function:
  23.     
  24. An IdentSet is like a Set, except keys are compared using
  25. isSame() rather than isEqual().
  26.  
  27. $Log:    IdentSet.c,v $
  28.  * Revision 3.0  90/05/20  00:19:50  kgorlen
  29.  * Release for 1st edition.
  30.  * 
  31. */
  32.  
  33. #include "IdentSet.h"
  34.  
  35. #define    THIS    IdentSet
  36. #define    BASE    Set
  37. #define BASE_CLASSES BASE::desc()
  38. #define MEMBER_CLASSES
  39. #define VIRTUAL_BASE_CLASSES
  40.  
  41. DEFINE_CLASS(IdentSet,0,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/IdentSet.c,v 3.0 90/05/20 00:19:50 kgorlen Rel $",NULL,NULL);
  42.  
  43. IdentSet::IdentSet(unsigned size) : BASE(size) {}
  44.  
  45. int IdentSet::findIndexOf(const Object& ob) const
  46. /*
  47. Search this IdentSet for the argument object.
  48.  
  49. Enter:
  50.     ob = object to search for
  51.  
  52. Returns:
  53.     index of object if found or of nil slot if not found
  54.     
  55. Algorithm L, Knuth Vol. 3, p. 519
  56. */
  57. {
  58.     register int i;
  59.     for (i = h((const int)&ob); contents[i]!=nil; i = (i-1)&mask) {
  60.         if (contents[i]->isSame(ob)) return i;
  61.     }
  62.     return i;
  63. }
  64.  
  65. IdentSet::IdentSet(OIOin& strm)
  66. :
  67. #ifdef MI
  68.     Object(strm),
  69. #endif
  70.     BASE(strm)
  71. {
  72. }
  73.  
  74. IdentSet::IdentSet(OIOifd& fd)
  75. :
  76. #ifdef MI
  77.     Object(fd),
  78. #endif
  79.     BASE(fd)
  80. {
  81. }
  82.